import request from '@/utils/request';

interface SolutionItem {
  solutionId: string;
  solutionTitle: string;
  picUrl: string;
  solutionItemContentBind?: string;
}

interface ListResponse {
  list: SolutionItem[];
  total: number;
}

export async function qrySolutionListPage(params: {
  pageIndex?: number;
  pageSize?: number;
  param?: {
    solutionTitle?: string;
  };
}): Promise<ListResponse> {
  const response = await request('/solution/qrySolutionListPage', {
    method: 'POST',
    data: params,
  });
  return {
    list: response.data || [],
    total: response.total || 0,
  };
}

export async function qrySolutionDetail(params: {
  solutionId: string;
}): Promise<SolutionItem> {
  const response = await request('/solution/qrySolutionDetail', {
    method: 'POST',
    data: params,
  });
  return response.data;
}

export async function addSolution(params: {
  solutionTitle: string;
  picUrl: string;
  solutionItemContentBind: string;
}): Promise<void> {
  await request('/solution/addSolution', {
    method: 'POST',
    data: params,
  });
}

export async function updateSolution(params: {
  solutionId: string;
  solutionTitle: string;
  picUrl: string;
  solutionItemContentBind: string;
}): Promise<void> {
  await request('/solution/updateSolution', {
    method: 'POST',
    data: params,
  });
}

export async function deleteSolution(params: {
  solutionId: string;
}): Promise<void> {
  await request('/solution/deleteSolution', {
    method: 'POST',
    data: params,
  });
}
